#include "EpilLocalFunctionStatementCode.h"
#include "EpilOutputHelper.h"
#include "EpilParserException.h"
#include "EpilPointerHelper.h"

using namespace std;


EpilLocalFunctionStatementCode::EpilLocalFunctionStatementCode( const EpilLexLocation & location )
: EpilStatementCodeBase( location )
, m_body( NULL )
, m_name( t("") )
{
}


EpilLocalFunctionStatementCode::~EpilLocalFunctionStatementCode()
{
	EpilPointerHelper::SafeDelete( m_body );
}


tstring EpilLocalFunctionStatementCode::ToEpilCode( int indent ) const
{
	tstringstream ret;
	ret << EpilOutputHelper::GetIndent( indent );
	ret << t("local function ");
	ret << m_name;
	ret << m_body->GetParameterList()->ToEpilCode();
	ret << endl;
	ret << m_body->GetChunk()->ToEpilCode( indent + 1 );
	ret << endl;
	ret << EpilOutputHelper::GetIndent( indent );
	ret << t("end");
	ret << endl;
	return ret.str();
}